<script src="{{ getAssets }}js/amazeui.datatables.min.js?v={{ assets_version }}"></script>
<script src="{{ getAssets }}js/jquery.table2excel.min.js?v={{ assets_version }}"></script>
<script>
    var curing;
    var tables = $('#dataTables').DataTable({
        "sAjaxSource": '{{ urlfor "GspController.CuringPlan"}}'
        , "bLengthChange": false
        , "fnServerData": function (sSource, aoData, fnCallback) {
            var queryParams = checkQueryTableData(aoData);
            var form = $('.query-form').serializeArray();
            $.each(form, function(i, value){
                queryParams[value.name] = value.value;
            });
            $.post(sSource, JSON.stringify(queryParams),function(resp) {
                isLoading = true;
                fnCallback(resp);
            },'json');
        }
        , order: []
        , columns: [
            {
                "bSortable": false, render: function (data, type, full, meta) {
                    return productTypeidName(full.Products.TypeId);
                }
            }
            , {
                "bSortable": false, render: function (data, type, full, meta) {
                    return full.Products.BrandName;
                }
            }
            , {
                "bSortable": false, render: function (data, type, full, meta) {
                    return full.Products.Name;
                }
            }
            , {
                "bSortable": false, render: function (data, type, full, meta) {
                    return full.Products.ColourNumber;
                }
            }
            , {
                "bSortable": false, render: function (data, type, full, meta) {
                    return full.Products.Spec;
                }
            }
            , {
                "bSortable": false, render: function (data, type, full, meta) {
                    return full.Products.CastAway;
                }
            }
            , {
                "bSortable": false, render: function (data, type, full, meta) {
                    return full.Products.ShelfLife;
                }
            }
            , {
                "bSortable": false, render: function (data, type, full, meta) {
                    return full.Products.Unit;
                }
            }
            , {
                "bSortable": false, render: function (data, type, full, meta) {
                    return full.Inventory.Snd.sph;
                }
            }
            , {
                "bSortable": false, render: function (data, type, full, meta) {
                    return full.Inventory.Snd.cyl;
                }
            }
            , {
                "bSortable": false, render: function (data, type, full, meta) {
                    return timetransDate(full.manufacture_date);
                }
            }
            , {
                "bSortable": false, render: function (data, type, full, meta) {
                    return timetransDate(full.expiry_date);
                }
            }
            , {
                "bSortable": false, render: function (data, type, full, meta) {
                    return full.lot_number;
                }
            }
        ]
        ,"aLengthMenu": [20, 50, 100, 200]
		,'bLengthChange': true
        , "serverSide": true
        , "bPaginate": true
        , "bFilter": false	//是否启动过滤、搜索功能
        , "bInfo": true //是否显示页脚信息，DataTables插件左下角显示记录数
        , "bProcessing": true //DataTables载入数据时，是否显示‘进度’提示
    });
    var isLoading = false;
    $('#download').bind("click", function(){
        if(isLoading) {
            $("#dataTables").table2excel({

                exclude: ".noExl",

                name: "导出养护计划清单",

                filename: "养护计划清单",

                fileext: ".xls",

                exclude_img: false,

                exclude_links: false,

                exclude_inputs: false
            });
        } else {
            $("#searchsubmit").click();
            layer.msg("还没加载结束请耐心等待一下！");return false;
        }
        return false;
    });
</script>
